package cn.sjx.sys.service.impl;

import cn.sjx.sys.domain.Dictionary;
import cn.sjx.sys.mapper.DictionaryMapper;
import cn.sjx.sys.mapper.DictionaryitemMapper;
import cn.sjx.sys.service.IDictionaryService;
import cn.sjx.basic.service.impl.BasicServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sjx
 * @since 2023-05-09
 */
@Service
public class DictionaryServiceImpl extends BasicServiceImpl<Dictionary> implements IDictionaryService {

    @Autowired
    DictionaryMapper dictionaryMapper;
    @Autowired
    DictionaryitemMapper dictionaryitemMapper;
    @Override
    public void batchRemove(List<Long> ids) {
        dictionaryMapper.batchRemove(ids);
        dictionaryitemMapper.deleteByParentId(ids);
    }

    @Override
    public void deleteById(Serializable id) {
        dictionaryMapper.deleteById(id);
        List<Long> ids = new ArrayList<>();
        ids.add((Long) id);
        dictionaryitemMapper.deleteByParentId(ids);
    }
}
